<template>
  <a-modal :open="open" width="1100px" title="执行明细" destroy-on-close centered :ok-button-props="{ hide: true }" @cancel="onCancel">
    <a-form :model="params" layout="inline" class="m-8">
      <div class="flex justify-between items-end border-b-2">
        <a-descriptions class="mt-3" :column="4">
          <a-descriptions-item label="员工名称"> {{ params?.empName || '-' }}</a-descriptions-item>
          <a-descriptions-item label="员工编号">{{ params?.zxr || '-' }}</a-descriptions-item>
          <a-descriptions-item label="处置项目名称"> {{ params?.mc || '-' }}</a-descriptions-item>
          <a-descriptions-item label="执行次数">{{ params?.allzxcs || '-' }}</a-descriptions-item>
        </a-descriptions>
      </div>

      <BaseTable class="mt-4" column-code="001036" :data-source="tableData" :loading="loading" :height="400" :scroll="{ x: 1200, y: 320 }" :pagination="null">
        <template #bodyCell="{ column, index, record }">
          <template v-if="column.dataIndex === 'xh'">{{ index + 1 }}</template>
          <!-- ly  0 门诊 1 住院 -->
          <template v-if="column.dataIndex === 'ly'">
            <div v-if="record.ly === 0">门诊</div>
            <div v-if="record.ly === 1">住院</div>
          </template>
        </template>
      </BaseTable>
    </a-form>
  </a-modal>
</template>
<script setup>
import { ref, watch } from 'vue'
import BaseTable from '@/components/BaseTable'

const emit = defineEmits(['update:open'])

const props = defineProps({
  open: {
    type: Boolean,
    default: false
  },
  rowData: {
    type: Object,
    default: () => ({})
  }
})
const params = ref({})

const onCancel = () => {
  emit('update:open', false)
}

const { loading, tableData, getData } = useTable({
  pagination: false,
  url: '/inp/zyhs/getWorkloadStatisticsRetrievalDetailsList',
  formatParams: () => {
    return {
      ...params.value
    }
  }
})

watch(
  () => props.open,
  (val) => {
    if (val) {
      params.value = { ...props.rowData }
      getData()
    }
  }
)
</script>
<style lang="less" scoped></style>
